package flc.ast.activity;

import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.stark.more.MoreUiUtil;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.databinding.ActivitySettingBinding;
import stark.common.basic.event.EventStatProxy;

public class SettingActivity extends BaseAc<ActivitySettingBinding> {


    @Override
    protected int onCreate() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initView() {
        mDataBinding.ivSettingBack.setOnClickListener(v -> getOnBackPressedDispatcher().onBackPressed());

        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(this, mDataBinding.event5Container);

        mDataBinding.ivSettingsRecom.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        if (v.getId() == R.id.ivSettingsRecom) {
            boolean isOpened = MoreUiUtil.isPersonalRecommendOpened();
            MoreUiUtil.setPersonalRecommendOpened(!isOpened);
            if (isOpened) {
                mDataBinding.ivSettingsRecom.setImageResource(R.drawable.agxhg);
            } else {
                mDataBinding.ivSettingsRecom.setImageResource(R.drawable.agxhk);
            }
        }
    }

    @Override
    protected void initData() {
        boolean isOpened = MoreUiUtil.isPersonalRecommendOpened();
        if (isOpened) {
            //将控件开关设为开
            mDataBinding.ivSettingsRecom.setImageResource(R.drawable.agxhk);
        } else {
            //将控件开关设为关
            mDataBinding.ivSettingsRecom.setImageResource(R.drawable.agxhg);
        }
    }
}